<?php
////////////////////////////////////////////////////////////////////////////////
//   Copyright (C) ReloadCMS Development Team                                 //
//   http://reloadcms.com                                                  //
//                                                                            //
//   This program is distributed in the hope that it will be useful,          //
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
//                                                                            //
//   This product released under GNU General Public License v2                //
////////////////////////////////////////////////////////////////////////////////
define('ARTICLES_PATH', DATA_PATH . 'a/');
include_once("api.datamng.php");
include_once("api.mysql.php");

class articles{
	var $containers = array();
	var $categories = array();
	var $articles = array();
	var $container = '';
	var $index = array();
	var $last_error = '';

	//---------------------------------------------------------------------------------//
	// Containers

	function getContainers($all = 1){   
       $datamng=new DataMng();
       $datamng->BeginRawDataRead("SELECT * FROM ".$datamng->prefix."containers");
       while ($row = $datamng->Read()) {
		  $this->containers[$row['id']]=$row['title'];     
       }
       return $this->containers;
    } 

	function setWorkContainer($id){
		if(empty($id) || preg_replace("/#{0,1}[\d\w]+/i", '', $id) != '') {
			$this->last_error = __('Invalid ID');
			return false; }
			
	$this->container = $id;
	return $id; 
	}

	function createContainer($id, $title){
		
	}

	function editContainer($id, $newid, $newtitle){
		
	}

	function removeContainer($id){
		
	}

	//---------------------------------------------------------------------------------//
	// Categories

	function getCategories($short = false, $parse = true, $ret_last_article = false){
		if(empty($this->container)){
			$this->last_error = __('No section selected!');
			return false;
		}
		
		if($this->container == '#root' || $this->container == '#hidden'){
			$this->last_error = __('This system section doesn\'t have categories');
			return false;
		} 
		
	   $datamng=new DataMng();
       $datamng->BeginRawDataRead("SELECT * FROM ".$datamng->prefix."categories");
              
       while ($row = $datamng->Read()) {
       		  $this->categories[$row['id']]=$row['title'];     
       	
       }
       print_r($this->categories);
    
      // return $this->categories;
		
	}

	function getCategory($cat_id = 0, $parse = true, $ret_last_article = false){
		
		
	}

	function createCategory($title, $desc = '', $icon = array(), $access = 0) {
		
	}

	function editCategory($cat_id, $title, $desc, $icon = array(), $access = 0, $killicon = false) {
		
	}

	function deleteCategory($cat_id) {
		
	}

	//---------------------------------------------------------------------------------//
	// Articles

	function getArticles($cat_id, $parse = true, $desc = false, $text = false) {
		
	}

	function getArticle($cat_id, $art_id, $parse = true, $desc = false, $text = false, $cnt = false) {
		
	}

	function saveArticle($cat_id, $art_id, $title, $src, $keywords, $sef_desc, $desc, $text, $mode = 'text', $comments = 'yes') {
	
	}

	function moveArticle($cat_id, $art_id, $new_cat_id) {
		
	}

	function moveArticleToContainer($src_container, $cat_id, $art_id, $new_container, $new_cat_id = 0) {
		
	}

	function deleteArticle($cat_id, $art_id) {
		
	}

	//---------------------------------------------------------------------------------//
	// Comments

	function getComments($cat_id, $art_id) {
		
	}

	function addComment($cat_id, $art_id, $text) {
				
	}

	function deleteComment($cat_id, $art_id, $comment) {
		
	}

	//---------------------------------------------------------------------------------//
	// Index file

	function getIndex(){
		
	}

	function getStat($param, $cat_id = 0, $recent_only = false){
		
	}

	function getLimitedStat($param, $limit, $reverse = false){
		
	}

	function saveIndex() {	
			
      }
}
  ?>